package com.cxcy.swustlearner.service.Impl;

import com.cxcy.swustlearner.mapper.UserMapper;
import com.cxcy.swustlearner.pojo.PageBean;
import com.cxcy.swustlearner.pojo.User;
import com.cxcy.swustlearner.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> getUsersById(int id) {
        return List.of();
    }
    @Override
    public List<User> getUsersByName(String username) {
        return List.of();
    }
    @Override
    public PageBean GetAllUsers(User user,int page,int pagesize) {
        PageHelper.startPage(page,pagesize);
        List<User> list = userMapper.GetAllUsers(user);
        Page<User> p=(Page<User>) list;
        return new PageBean(p.getTotal(),p.getResult());
    }
    @Override
    public List<User> getAllUsers() {
        return List.of();
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }
}